# gil global interpreter lock (cpython)
import threading
from threading import Lock

total=0
lock = Lock()

def add():
    global total,lock
    for i in range(10000000):
        lock.acquire()
        total += i
        lock.release()
def des():
    global total,lock

    for i in range(10000000):
        lock.acquire()
        total -= i
        lock.release()


if __name__ == '__main__':
    a=threading.Thread(target=add)
    b=threading.Thread(target=des)
    a.start()
    b.start()

    a.join()
    b.join()

    print(total)